#include "stdafx.h"
#include "Assistant.h"


Assistant::Assistant(void)
{
}


Assistant::~Assistant(void)
{
}

string Assistant::getPassword()
{
	return _password;
}

void Assistant::setPassword(string password_)
{
	_password = password_;
	ENSURE0(_password == password_);
}

bool Assistant::changePassword(string oldPassword_, string newPassword_)
{
	_db.connect();
	if (_db.checkPassword(oldPassword_))
	{
		_db.editPassword(newPassword_);
		_db.close();
		return true;
	}
	else
	{
		_db.close();
		return false;
	}
}

string Assistant::creatAccount(MemberDetails details_)
{
	const string password = "abc123";
	_db.connect();
	_db.addAccount(details_);

	_db.close();
	return password;

}

MemberDetails Assistant::searchAccount(string userName_)
{
	MemberDetails memberDet;
	_db.connect();

	memberDet = _db.searchMemberDetails(userName_);

	_db.close();
	return memberDet;

}

void Assistant::addPiece(int movieID_, string barcode_)
{
	_db.connect();
	_db.addDVD(movieID_, barcode_);
	_db.close();
}

void Assistant::removePiece(int movieID_, string barcode_)
{
	_db.connect();
	_db.removeDVD(movieID_, barcode_);
	_db.close();
}

void Assistant::addMovie(Movie movie_)
{
	_db.connect();
	_db.addFilm(movie_);
	_db.close();
}

void Assistant::addRental(DVD dvd_)
{
	_db.connect();
	//_db.rentFilm(dvd_);
	_db.close();
}

void Assistant::removeRental(DVD dvd_)
{
	_db.connect();
	//_db.endRentFilm(dvd_);
	_db.close();
}
